package com.piggy.msg.server.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.piggy.common.core.utils.PageUtils;
import com.piggy.common.core.web.domain.AjaxResult;
import com.piggy.common.core.web.page.TableDataInfo;
import com.piggy.msg.domain.EmailLogs;
import com.piggy.msg.server.service.EmailLogsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 邮件发送日志 前端控制器
 *
 * @author admin
 * @date 2019-07-25
 */
@Api(value = "邮件发送日志", tags = "邮件发送日志")
@RestController
@RequestMapping("/emailLogs")
    public class EmailLogsController {

    @Autowired
    private EmailLogsService targetService;

    /**
     * 获取分页数据
     *
     * @return
     */
    @ApiOperation(value = "获取分页数据", notes = "获取分页数据")
    @GetMapping(value = "/list")
    public TableDataInfo list(@RequestParam(required = false) EmailLogs emailLogs) {
        QueryWrapper<EmailLogs> queryWrapper = new QueryWrapper();
        return  PageUtils.buildDataInfo(targetService.page(PageUtils.buildPage(), queryWrapper));

//        PageParams pageParams = new PageParams(map);
//        EmailLogs query = pageParams.mapToObject(EmailLogs.class);
//        QueryWrapper<EmailLogs> queryWrapper = new QueryWrapper();
//        return AjaxResult.success().data(targetService.page(new PageParams(map), queryWrapper));
    }

    /**
     * 根据ID查找数据
     */
    @ApiOperation(value = "根据ID查找数据", notes = "根据ID查找数据")
    @ResponseBody
    @RequestMapping("/get")
    public AjaxResult get(@RequestParam("id") Long id) {
        EmailLogs entity = targetService.getById(id);
        return AjaxResult.success(entity);
    }

}
